const express = require('express');
const router = express.Router();
const { 
    createOrder, 
    getOrders, 
    getOrder, 
    cancelOrder,
    extendRental,
    completeOrder
} = require('../controllers/orderController');
const { createOrder: createOrderValidation } = require('../middleware/validator/orderValidator');
const { validateRequest } = require('../middleware/validator');
const { verifyToken } = require('../utils/jwt');

// 创建订单
router.post('/', verifyToken(), createOrderValidation, validateRequest, createOrder);

// 获取订单列表
router.get('/', verifyToken(), getOrders);

// 获取订单详情
router.get('/:id', verifyToken(), getOrder);

// 续租订单
router.post('/:id/extend', verifyToken(), extendRental);

// 完成订单
router.post('/:id/complete', verifyToken(), completeOrder);

// 取消订单
router.post('/:id/cancel', verifyToken(), cancelOrder);

module.exports = router; 